import com.weaverboot.weaComponent.impl.weaForm.impl.*;
import com.weaverboot.weaComponent.impl.weaForm.weaFormGroup.DefaultWeaFormGroup;
import com.weaverboot.weaResultMsg.impl.formResult.impl.WeaFormSendComponentResultMsg;

public class DemoService {
    public WeaFormSendComponentResultMsg getForm() {
        WeaFormSendComponentResultMsg weaFormResultMsg = new WeaFormSendComponentResultMsg();
        //创建一个输入框
        //第一个参数为组件的标签名，第二个为这个组件的前端id，随意填写即可，不要重复，下同，不赘述
        InputWeaForm inputWeaForm = new InputWeaForm("输入框", "input");
        //设置输入框的默认值为10
        inputWeaForm.setValue(10);
        //创建一个密码框
        PasswordWeaForm passwordWeaForm = new PasswordWeaForm("密码", "password");
        //创建一个上传文件
        UploadWeaForm uploadWeaForm = new UploadWeaForm("上传文件", "upload");
        //创建一个颜色选择器
        DateIntervalWeaForm colorPickerWeaForm = new DateIntervalWeaForm("颜色选择器", "colorpicker");
        //创建一个时间选择下拉框
        DateGroupWeaForm dateWeaForm = new DateGroupWeaForm("时间下拉框", "date");
        //创建一个只可选择年份的时间选择框
        DatePickerWeaForm datePickerWeaForm = new DatePickerWeaForm("时间","datepicker");
        //设置只可选择年份
        datePickerWeaForm.setFormat("yyyy");
        //创建一个富文本框
        RichTextForm richTextForm = new RichTextForm("富文本框", "richText");
        //创建一个下拉框
        SelectWeaForm selectWeaForm = new SelectWeaForm("下拉框", "selectItem");
        selectWeaForm.addOption("值1", "value1"); //值1，什么都不做
        selectWeaForm.addOption("值2", "value2").selected(); //值2，默认选中
        selectWeaForm.addOption("值3", "value3").disabled(); //值3，不可选
        //创建一个文本域
        TextAreaWeaForm textAreaWeaForm = new TextAreaWeaForm("文本域", "textArea");
        //创建一个选择框组件
        CheckBoxWeaForm checkWeaForm = new CheckBoxWeaForm("选择框", "checkboxT");
        //创建一个开关组件
        SwitchWeaForm switchWeaForm = new SwitchWeaForm("开关", "sitch");
        //建立一个分组，如没有特殊需求，类别默认为DefaultWeaFormGroup
        DefaultWeaFormGroup weaFormGroup = new DefaultWeaFormGroup();
        //设置分组名称
        weaFormGroup.setTitle("分组1");
        weaFormGroup.addItem(inputWeaForm).addItem(passwordWeaForm).addItem(uploadWeaForm).addItem(colorPickerWeaForm).addItem(dateWeaForm)
                .addItem(richTextForm).addItem(selectWeaForm).addItem(textAreaWeaForm).addItem(checkWeaForm).addItem(browserWeaForm).addItem(switchWeaForm).addItem(datePickerWeaForm); //将组件添加进分组
        //建立一个父级树
        DefaultWeaFatherTree weaFatherTree = new DefaultWeaFa();
        //设置父级树的名称
        weaFatherTree.setName("类型");
        //设置父级树的key
        weaFatherTree.setKey("100");
        //设置父级树的domid
        weaFatherTree.setDomid("type");
        //建立一个子树
        DefaultWeaChildTree childnode1 = new DefaultWeaChildTree();
        //设置子树的domid
        childnode1.setDomid("1");
        //设置子树的key
        childnode1.setKey("1");
        //设置子树的名称
        childnode1.setName("类型一");
        //将这个子树添加到父级树里
        weaFatherTree.addChild(childnode1);
        weaFormResultMsg.addTree(weaFatherTree);
        weaFormResultMsg.addItem(weaFormGroup); //将group添加进返回消息体
        return weaFormResultMsg;
    }
}
